import yaml
import os

from common.project_path import project_path


class ReadYaml:

    def __init__(self, file_path):
        if os.path.exists(file_path):
            self.file_path = file_path
        else:
            print(f"没有找到{file_path}文件")
        self.data = self.read_yaml()

    def read_yaml(self):

        with open(self.file_path, "r", encoding="utf-8") as file:
            test_data = file.read()
            test_datas = yaml.load(test_data, Loader=yaml.FullLoader)
        return test_datas


if __name__ == '__main__':
    RY = ReadYaml("/Users/jiayunkong/work_space/auto_api/data/test_register_data.yaml")
    test_datas = RY.read_yaml()
    print(test_datas)

    cases = ReadYaml(os.path.join(project_path, "data", "test_login_data.yaml")).read_yaml()
    print(f"====={cases}")
